<template>
  <div class="app-container">
    <!--表单-->
    <el-form :inline="true" class="demo-form-inline">

      <el-form-item label="日期">
        <el-date-picker
          v-model="day"
          type="date"
          placeholder="选择要统计的日期"
          value-format="yyyy-MM-dd"/>
      </el-form-item>

      <el-button
        :disabled="btnDisabled"
        type="primary"
        @click="create()">生成
      </el-button>
    </el-form>

  </div>
</template>

<script>
  import sta from '@/api/sta'

  export default {
    name: "create",
    data() {
      return {
        day: '',//日期
        btnDisabled: false,//按钮是否禁用
      }
    },
    methods: {
      //生成统计数据
      create() {
        //禁用按钮
        this.btnDisabled = true
        //调用方法
        sta.createByDay(this.day)
          .then(response => {//生成成功
            //提示
            this.$message({
              type: 'success',
              message: response.message
            })
            //启用按钮
            this.btnDisabled = false
          })
      }
    }
  }
</script>

<style scoped>

</style>
